package dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import bean.StudentBean;

@Repository(value = "stuDao")
public class StudentDao {

	@Autowired
	private SessionFactory sessionFactory;

	public void save_1() throws Exception {
		Session session = null;

		try {
			session = sessionFactory.getCurrentSession();
			StudentBean stu = new StudentBean();
			stu.setStuId(15);
			stu.setClassId("3");
			stu.setStuName("admin3");
			session.save(stu);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

	}

	public void save_2() throws Exception {
		Session session = null;
		try {

			session = sessionFactory.getCurrentSession();
			StudentBean stu = new StudentBean();
			stu.setStuId(16);
			stu.setClassId("3");
			stu.setStuName("admin3");
			session.save(stu);

		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

	}

}
